<?php
defined('IN_XLP') or exit('Access Denied');
$Document = array(
    'pageid'   => 'cash-index', //页面标示
    'pagename' => '提现列表', //当前页面名称
    'mycss'    => array('../jquery-ui/css/smoothness/jquery-ui-1.10.0.custom.min', 'content/order_table'), //加载的css样式表
    'myjs'     => array(), //加载的js脚本
    'footerjs' => array('content/fuelux/fuelux', '../jquery-ui/js/jquery-ui-1.10.0.custom.min', '../jquery-ui/js/jquery-ui-timepicker-addon','content/jquery.smoothConfirm'),
    'head'     => true, //加载头部文件
);
include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
<section id="content">
    <!-- main padder -->
    <section class="main padder">

        <div class="clearfix">
            <h4><i class="fa fa-table"></i>提现管理</h4>
        </div>

        <section class="panel">
            <header class="panel-heading bg-white">状态</header>
            <div class="panel-body">

                <div class="block">
                    <div class="btn-group">
                        <a href="<?php echo $status_url.'0'; ?>" class="btn  <?php if(@$_GET['status']!='0'){ ?>btn-white<?php } ?>">已取消</a>
                        <a href="<?php echo $status_url.'10'; ?>" class="btn <?php if(@$_GET['status']!=10){ ?>btn-white<?php } ?>">申请提现</a>
                        <a href="<?php echo $status_url.'30'; ?>" class="btn <?php if(@$_GET['status']!=30){ ?>btn-white<?php } ?>">财务审核</a>
                        <a href="<?php echo $status_url.'70'; ?>" class="btn <?php if(@$_GET['status']!=70){ ?>btn-white<?php } ?>">提现完成</a>
                        <a href="<?php echo U('cash/index'); ?>"  class="btn <?php if(@$_GET['status']!==''){ ?>btn-white<?php } ?>">全部</a>
                    </div>
                </div>
                
                <div class="row">
                    <div class="col-lg-12">
                        <section class="panel">
                            <header class="panel-heading">提现数据</header>
                            <div class="panel-body">
                                <div class="row text-small">
                                    <form action="<?php echo U('content/order/index'); ?>" method="get">
                                        <input type="hidden" name="g" value="content">
                                        <input type="hidden" name="c" value="order">
                                        <input type="hidden" name="m" value="index">
                                        <!-- <input type="hidden" name="status" value="<?php //echo $status; ?>"> -->
                                        
                                        <div class="col-sm-2 m-b-mini">
                                            <label for="">开始时间 <input class="input-sm" name="starttime" id="starttime" size="16" type="text" value="<?php echo $starttime; ?>" readonly ></label>
                                        </div>
                                        <div class="col-sm-2">
                                            <label for="">结束时间 <input class="input-sm" name="endtime" id="endtime" size="16" type="text" value="<?php echo $endtime; ?>" readonly ></label>
                                        </div>
                                        <div class="col-sm-1">
                                            <select name="searchtype" id="searchtype" class="form-control">
                                                <option value="1" <?php if($searchtype == 1) echo 'selected';?>>提现单号</option>
                                                <option value="3" <?php if($searchtype == 3) echo 'selected';?>>手机号</option>
                                            </select>
                                        </div>
                                        <div class="col-sm-2">
                                            <div class="input-group">
                                                <input type="text" class="input-sm form-control" placeholder="Search" name="keyword" id="keyword" value="<?php echo $keyword; ?>">
                                                <span class="input-group-btn">
                                                    <button class="btn btn-sm btn-white" type="submit">搜索</button>
                                                </span>
                                            </div>
                                        </div>
                                        <div class="col-sm-2">
                                            <div class="input-group">
                                                <!-- <a class="btn btn-sm btn-white" href="<?php echo $export_url; ?>">导出CSV</a> -->
                                                <a style="margin-left:25px;" class="btn btn-sm btn-white" href="<?php echo U('content/order/index'); ?>">搜索重置</a>
                                            </div>
                                        </div>
                                        <div style="padding-top:7px;margin-left:-60px;display:inline-block;">
                                            搜索结果：<b style="color:red;"><?php echo $order_total; ?></b> 个
                                        </div>
                                    </form>
                                </div>
                            </div>
                            
                            <div class="table-responsive">
                                <table class="table table-striped b-t text-small order">
                                    <thead>
                                        <tr>
                                            <th>提现编号</th>
                                            <th>申请人</th>
                                            <th>提现金额</th>
                                            <th>联系方式</th>
                                            <th>申请时间</th>
                                            <th>状态</th>
                                            <th>完成时间</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                      <?php
                                      if ($order_list){
                                          foreach($order_list as $val){
                                      ?>
                                        <tr id="list_detail_<?php echo $val['uid'];?>">
                                                  <td align="center"><b><?php echo $val['order_sn'];?></b></td>
                                                  <td align="center"><a rel="pop" href="<?php echo U('member/detail',array('uid'=>$val['uid']));?>" title="点击查看会员信息"><?php echo $val['name'];?></a></td>
                                                  <td align="center"><?php echo $val['amount'];?></td>
                                                  <td align="center"><?php echo $val['phone'];?></td>
                                                  <td align="center"><?php echo ($val['create_time']?outTime($val['create_time']):'');?></td>
                                                  <td align="center" id="set_user_id_<?php echo $val['id'] ?>"><?php echo $orderStateArry[$val['status']];?></td>
                                                  <td align="center"><?php echo ($val['finish_time']?outTime($val['finish_time']):'');?></td>
                                                  <td align="center">
                                                    <?php if(($val['status'] == 10) && admin::$adminInfo['groupid'] == 1){ ?>
                                                        <a href="javascript:;" onclick="changeFirstState(this);" data-id="<?php echo $val['id'] ?>">管理审核</a>
                                                    <?php }else if($val['status'] == 30 && admin::$adminInfo['groupid'] == 2){ ?>
                                                        <a href="javascript:;" onclick="changeSecondState(this);" data-id="<?php echo $val['id'] ?>">财务审核</a>
                                                    <?php } ?>
                                                  </td>
                                                </tr>
                                                <?php
                                                  }
                                              }else{
                                                ?>
                                               <tr>
                                                  <td colspan="20" align="center">暂无数据</td>
                                                </tr>
                                              <?php
                                              }
                                              ?>
                                      </tbody>
                               </table>
                            </div>
                            
                            <footer class="panel-footer">
                                <div class="row">
                                    <div class="col-sm-12 text-right text-center-sm">
                                        <?php echo page($order_total,$page,'',20,'page');?>
                                    </div>
                                </div>
                            </footer>

                        </section>
                    </div>
                </div>

            </div>

        </section>

    </section>
    <!--/ main padder -->
</section>
<!--/ content -->
<!--主体 结束-->
<script>
$(function(){
    $('#starttime').datetimepicker();
    $('#endtime').datetimepicker();
});

function changeFirstState(obj) {
  var id=$(obj).attr('data-id');
  $(obj).smoothConfirm("请选择操作类型", {
      okVal:'通过',
      cancelVal:'失败',
      ok: function() {
        Msg.loading();
        $.post('<?php echo U('cash/changeCashStatus');?>',{"id":id,"status":30},function(result){
          Msg.hide();
          $("#set_user_id_"+id).html('<?php echo $orderStateArry[30] ?>');
          $(obj).hide();
        },'json');
      },
      cancel: function() {
          $.post('<?php echo U('cash/changeCashStatus');?>',{"id":id,"status":0},function(result){
            Msg.hide();
            $("#set_user_id_"+id).html('<?php echo $orderStateArry[0] ?>');
          },'json');
      }
    });
}

function changeSecondState(obj) {
  var id=$(obj).attr('data-id');
    $(obj).smoothConfirm("请选择操作类型", {
      okVal:'通过',
      cancelVal:'取消',
      ok: function() {
        Msg.loading();
        $.post('<?php echo U('cash/changeCashStatus');?>',{"id":id,"status":70},function(result){
            Msg.hide();
            if(result.status) {
                $("#set_user_id_"+id).html('<?php echo $orderStateArry[70] ?>');
                $(obj).hide();  
            }else{
                Msg.error(result.info);
                return false;
            }
          
        },'json');
      },
      cancel: function() {
         
      }
    });
}
</script>
<?php include getTpl('footer', 'public'); ?>
<script>
(function($){
    $.fn.extend({ 
    "SetTableList":function(options){}
    });
})(jQuery);
</script>